<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>33.2-图书案例-$set修改数组数据</title>
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
    <style></style>
  </head>
  <body>
    <div id="app">
      <ul>
        <li v-for="(item, index) in list" :key="index">{{item}}</li>
      </ul>
      <div class="box">
        <div>{{obj.name}}</div>
        <div>{{obj.sex}}</div>
        <div>{{obj.sayHi}}</div>
      </div>
    </div>
    <script>
      var vm = new Vue({
        el: '#app',
        data: {
          list: ['apple', 'orange', 'banana'],
          obj: {
            name: 'zs',
            sex: '男',
          },
        },
        methods: {},
      });
      vm.$set(vm.list, 1, 'watermelon'); // 修改数据
      vm.$set(vm.obj, 'sayHi', 'Hello'); // 对象中添加
    </script>
  </body>
</html>
